#ifndef ACTOR_H
#define ACTOR_H
#include "object_world.h"

class AffiliateBar;
class Stats;

class Actor : public ObjectWorld {
protected:
    Stats *stats_ = nullptr;
    AffiliateBar *healthBar_ = nullptr;
    glm::vec2 velocity_ = glm::vec2(10); // 速度
    float max_speed_ = 100; // 最大速度
public:
    void update(float dt) override;

    void move(float dt); // 移动函数
    float getMaxSpeed() const { return max_speed_; } // 获取最大速度
    void setMaxSpeed(float max_speed) { max_speed_ = max_speed; } // 设置最大速度
    void setVelocity(const glm::vec2 &velocity) { velocity_ = velocity; } // 设置速度
    glm::vec2 getVelocity() const { return velocity_; } // 获取速度
    void setStats(Stats *stats) { stats_ = stats; }
    Stats *getStats() const { return stats_; }

    void takeDamage(float damage) override;

    bool isAlive() const;

    void setHealthBar(AffiliateBar *healthBar) {
        healthBar_ = healthBar;
    }

    AffiliateBar *getHealthBar() const { return healthBar_; }

private:
    void updateHealthBar();
};

#endif // ACTOR_H
